home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
RTF
/
view.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
3KB
|
150 lines
/* $Header: /usr/people/pcd/Src/RTF/RCS/view.h,v 1.1 92/11/23 12:58:53 pcd Exp Locker: pcd $
*/
#ifndef __view_h
#define __view_h
#include "textflow.h"
#include "textrect.h"
#include "elements.h"
#include "rtftoken.h"
class RTFPos : public RTF{
public:
RTFPos(const char* text)
{ start_ = end_ = 0; p = text;};
TextPosition start()
{ return start_; };
TextPosition end()
{ return end_; };
void getText();
void getHex();
protected:
void _GetToken()
{ start_ = end_;
RTF::_GetToken();
if(CheckCMM(Control, PictAttr, PicBinary)) //@# need this?
end_ +=Param();
};
int next_char()
{ end_++; return *p++; }
void pushback(int)
{ p--; end_--; };
private:
TextPosition start_, end_;
const char* p;
};
class View{
public:
View();
~View();
virtual unsigned long color(int , int, int) const
{ return 0; };
virtual Coord hinches(double inches) const
{ return (Coord)inches; }
virtual Coord vinches(double inches) const
{ return (Coord)inches; };
virtual void text_flow(TextFlow&, TextPosition, TextPosition,
const CharacterFormat&)
{};
virtual void text_char(TextFlow&, TextPosition, TextPosition, char,
const CharacterFormat&)
{};
virtual void new_line(TextFlow&, TextPosition, TextPosition,
Inches)
{};
virtual void picture(TextFlow&, TextPosition, TextPosition,
Coord, Coord)
{};
void parse_text(RTFPos&, TextFlow&, const CharacterFormat&);
TextFlow* ASCII(const char* data, Qty q);
TextFlow* RichText(const char* data, Qty q);
static char* plain_text(const char* rich_text, Qty q);
int string(const char*, int);
/* USE : view->string(char* data, rtf)
* return 0 on errors
*****************/
int resize(BRect);
int resize(Coord x, Coord y, Coord w, Coord h)
{ BRect b(x, y, w, h);
return resize(b); };
int range(TextPosition, TextPosition);
Coord page_height()
{ return format() ? bounds().height() : 0; };
Coord height() const
{ return bounds().height(); };
Coord width() const
{ return bounds().width(); };
TextPosition position(Coord x, Coord y)
{ return page_ ? page_->position(x,y) : 0; }; //@@ default answer 0?
TextPosition first() const
{ return first_; };
TextPosition last() const
{ return last_; };
const BRect& bounds() const
{ return bounds_; };
protected:
virtual void clear()
{};
int format();
void unformat();
void parse_picture(RTFPos&, TextFlow&);
TextFlow* flow_;
TextRect* page_;
BRect bounds_;
TextPosition first_, last_;
};
class RTFCharacterFormat : public CharacterFormat{
public:
RTFCharacterFormat(RTFCharacterFormat* p)
{ if(p) *this = *p; parent_ = p; };
RTFCharacterFormat* parent()
{ return parent_; };
RTFCharacterFormat* pop()
{ RTFCharacterFormat* r = parent_;
if(r) {
delete this; return r;
} else return this;
};
void set_attr(int attr, int val);
char* spec();
private:
RTFCharacterFormat* parent_;
};
#endif